package giit.computerbase.server;

import giit.computerbase.dao.SQL;
import giit.computerbase.dao.SQLFactory;
import giit.computerbase.util.Application;

import java.sql.SQLException;

/**
 * User: tum0r
 * Package Name: giit.computerbase.server
 * Time: 2018-11-29 Thursday 00:58:28
 */
public class IndexServer {
    private SQL sql;

    public IndexServer() {
        try {
            sql = SQLFactory.getSQL();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public boolean judge() {
        boolean flag = true;
        flag = sql.open((String) Application.getConfig().databaseConfig.get("address"),
                (int) Application.getConfig().databaseConfig.get("port"),
                Application.DATABASE_NAME,
                (String) Application.getConfig().databaseConfig.get("encode"),
                (String) Application.getConfig().databaseConfig.get("user"),
                (String) Application.getConfig().databaseConfig.get("password"));

        try {
            sql.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return flag;
    }
}
